<?php
/**
 * Object Relational Persistence Mapping Class for table: pha_ewh_exticket_detail
 *
 * @package	modules.dept_pharmacy.ordo
 * @author	viethd
 * @version $
 * @copyright 2009 LHV Company
 */
class PhaEwhExticketDetail extends ORDataObject {

	/**#@+
	 * Fields of table: pha_ewh_exticket_detail mapped to class members
	 */
	var $pha_ewh_exticket_detail_id		= '';
	var $pha_ewh_exticket_id		= '';
	var $pha_drug_material_id		= '';
	var $req_quantity		= '';
	var $approve_quantity		= '';
	var $note		= '';
	var $accepted		= '';
	var $pha_req_exticket_detail_id		= '';
	/**#@-*/


	/**
	 * DB Table
	 */
	var $_table = 'pha_ewh_exticket_detail';

	/**
	 * Primary Key
	 */
	var $_key = 'pha_ewh_exticket_detail_id';
	
	/**
	 * Internal Name
	 */
	var $_internalName = 'PhaEwhExticketDetail';

	/**
	 * Handle instantiation
	 */
	function __construct() {
		parent::ORDataObject();
	}
	
	public function setData($data =array()) {
	    if (is_array($data)) {
	        $this->populateArray($data);
	    }
	}
	
	public function listItemOfGivenExTicket($exTicketId) {
	    $ds =& new Datasource_sql();
        $sql = array(
               'cols'  => "t.pha_ewh_exticket_detail_id",
               'from'  => "$this->_table t INNER JOIN pha_ewh_exticket pee
                            ON (t.pha_ewh_exticket_id=pee.pha_ewh_exticket_id
                                                     AND t.pha_ewh_exticket_id='$exTicketId')"
        );
        $ds->setup($this->_db, $sql);
        $result = $ds->toArray();        
        return $result;
	}
	
    public function deleteItem($phaEwhExticketDetailId) {
         
        $sql = "DELETE FROM $this->_table WHERE pha_ewh_exticket_detail_id='$phaEwhExticketDetailId'";
        $this->_execute($sql);

    }
	
}
?>
